from django.test import TestCase
from django.urls import reverse
from .models import Person as PersonModel

# Create your tests here.
class PersonModelTest(TestCase):

    def test_ageIsCorrect(self):
        '''
        检查用户姓名是否小于18
        :return:
        '''
        persons=PersonModel.objects.all()

        self.assertEqual(len(persons),1,str(persons))

class PersonIndexTest(TestCase):

    def test_personIndex(self):
        '''
        用户首页测试
        :return:
        '''
        response=self.client.get(reverse('myapp:index'))
        # self.assertContains(response,'No polls are available.')
        self.assertContains(response,'hello index')
        self.assertQuerysetEqual(response.context['persons'],[])